﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Xml;

namespace iLangl.Model
{
	public class ProjectTPRequestContext : ProjectRequestContext
	{

		public override void InitExtendedInfo(XmlWriter document)
		{
			Hashtable addedcompanies = new Hashtable();

			CompanyRequestContext context = new CompanyRequestContext();
			context.SetContext(_project.Owner.Company);
			context.Write(writer);
			addedcompanies[_project.Owner.Company.Id] = true;


			if (addedcompanies[_project.TechnicalContact.Company.Id] == null)
			{
				context.SetContext(_project.TechnicalContact.Company);
				context.Write(writer);

				addedcompanies[_project.TechnicalContact.Company.Id] = true;
			}

			//Add Company of Responsible persons by Translation
			foreach (Translation trans in _project.Translations)
			{
				if (trans.Responsible == null)
					continue;

				if (addedcompanies[trans.Responsible.Company.Id] == null)
				{
					context.SetContext(trans.Responsible.Company);
					context.Write(writer);
					addedcompanies[trans.Responsible.Company.Id] = true;
				}
			}
		}
	}
}
